<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>固定定位</title>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            .box{
                height: 40px;
                position: sticky;
                top: 0;
                background: white;
                width: 100%;
            }
            ul{
                width: 1000px;
                height: 40px;
                background: #00c0a5;
                margin: auto;
            }
            li{
                width: 100px;height: 40px;
                background: #4d8000;
                float: left;
                list-style: none;
                border: 1px solid bisque;
            }
            #box1,#box2,#box3,#box4,#box5{
                width: 1000px;
                height: 500px;
            }
           /* !*伪类目标选择器，当选中目标时产生效果*!
            #box1:target,#box2:target,#box3:target,#box4:target,#box5:target{
                margin-top: 100px;
            }*/
        </style>
    </head>
    <body>
        <div class="box">
            <ul>
                <li><a href="#box1">小米1</a></li>
                <li><a href="#box2">小米2</a></li>
                <li><a href="#box3">小米3</a></li>
                <li><a href="#box4">小米4</a></li>
                <li><a href="#box5">小米5</a></li>
            </ul>
        </div>
        <div id="box1" style="background: pink">小米1</div>
        <div id="box2" style="background: orangered">小米2</div>
        <div id="box3" style="background: yellow">小米3</div>
        <div id="box4" style="background: greenyellow">小米4</div>
        <div id="box5" style="background: bisque">小米5</div>
    </body>
</html>